<template>
  <div class="divBox order">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <div class="container">
          <el-form size="small" label-width="100px" inline>
            <el-form-item
              :label="$t('orderstatus')"
              style="display: block"
              class="is_Scroll"
            >
              <el-radio-group
                v-model="tableFrom.status"
                type="button"
                @change="getList(1), getCardList()"
              >
                <el-radio-button label
                  >{{ $t("all") }}
                  {{
                    "(" + orderChartType.all ? orderChartType.all : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="1"
                  >{{ $t("pendingpayment") }}
                  {{
                    "(" + orderChartType.unpaid
                      ? orderChartType.unpaid
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="2"
                  >{{ $t("tobedelivered") }}
                  {{
                    "(" + orderChartType.unshipped
                      ? orderChartType.unshipped
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="8"
                  >{{ $t("To.picked.up") }}
                  {{
                    "(" + orderChartType.pickup
                      ? orderChartType.pickup
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="3"
                  >{{ $t("pendingreceipt") }}
                  {{
                    "(" + orderChartType.untake
                      ? orderChartType.untake
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="4"
                  >{{ $t("comment") }}
                  {{
                    "(" + orderChartType.unevaluate
                      ? orderChartType.unevaluate
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="5"
                  >{{ $t("transactioncomplete") }}
                  {{
                    "(" + orderChartType.complete
                      ? orderChartType.complete
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="6"
                  >{{ $t("refunded") }}
                  {{
                    "(" + orderChartType.refund
                      ? orderChartType.refund
                      : 0 + ")"
                  }}</el-radio-button
                >
                <el-radio-button label="7"
                  >{{ $t("deleted") }}
                  {{
                    "(" + orderChartType.del ? orderChartType.del : 0 + ")"
                  }}</el-radio-button
                >
              </el-radio-group>
            </el-form-item>
            <el-form-item
              :label="$t('timeselection')"
              class="width100 is_Scroll"
              style="display: block"
            >
              <el-radio-group
                v-model="tableFrom.date"
                type="button"
                class="mr20"
                size="small"
                @change="selectChange(tableFrom.date)"
              >
                <el-radio-button
                  v-for="(item, i) in fromList.fromTxt"
                  :key="i"
                  :label="item.val"
                  >{{ item.text }}</el-radio-button
                >
              </el-radio-group>
              <el-date-picker
                v-model="timeVal"
                value-format="yyyy/MM/dd"
                format="yyyy/MM/dd"
                size="small"
                type="daterange"
                placement="bottom-end"
                :placeholder="$t('customtime')"
                style="width: 250px"
                @change="onchangeTime"
              />
            </el-form-item>
            <div>
              <el-form-item :label="$t('tradename')" class="width100">
                <el-input
                  v-model="tableFrom.store_name"
                  :placeholder="$t('Please5')"
                  class="selWidth"
                  size="small"
                  @keyup.enter.native="getList(1), getCardList()"
                >
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    size="small"
                    class="el-button-solt"
                    @click="getList(1), getCardList()"
                  />
                </el-input>
              </el-form-item>
              <el-form-item :label="$t('generalorderno')" class="width120">
                <el-input
                  v-model="tableFrom.group_order_sn"
                  :placeholder="$t('please94')"
                  class="selWidth"
                  size="small"
                  @keyup.enter.native="getList(1), getCardList()"
                >
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    size="small"
                    class="el-button-solt"
                    @click="getList(1), getCardList()"
                  />
                </el-input>
              </el-form-item>
              <el-form-item :label="$t('activitytype')" class="width100">
                <el-select
                  v-model="tableFrom.activity_type"
                  :placeholder="$t('pleaseselect')"
                  class="filter-item selWidth mr20"
                  clearable
                  @change="getList(1), getCardList()"
                >
                  <el-option
                    v-for="item in activityList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </div>
            <el-form-item
              :label="$t('keywords')"
              class="width100 is_Scroll"
              style="display: block"
            >
              <el-input
                v-model="tableFrom.keywords"
                :placeholder="$t('please44')"
                class="selWidth"
                size="small"
                @keyup.enter.native="getList(1), getCardList()"
              >
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  size="small"
                  class="el-button-solt"
                  @click="getList(1), getCardList()"
                />
              </el-input>
              <!-- <el-dropdown class="dropdown">
                <span class="el-dropdown-link">
                  {{ $t("listexport")
                  }}<i class="el-icon-arrow-down el-icon--right" />
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item @click.native="exportInvoice">{{
                    $t("generateshipmentdoc")
                  }}</el-dropdown-item>
                  <el-dropdown-item @click.native="exportOrder">{{
                    $t("generateorder")
                  }}</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown> -->
              <!-- <el-button
                size="small"
                type="primary"
                @click="getExportFileList"
                >{{ $t("exportrecords") }}</el-button
              > -->
            </el-form-item>
            <el-form-item
              :label="$t('userinformation')"
              class="width100 is_Scroll"
            >
              <el-input
                v-model="tableFrom.username"
                :placeholder="$t('please95')"
                class="selWidth"
                size="small"
                @keyup.enter.native="getList(1), getCardList()"
              >
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  size="small"
                  class="el-button-solt"
                  @click="getList(1), getCardList()"
                />
              </el-input>


             <!-- <el-button
                size="small"
                type="primary"
                @click="orderCancellation"
                >{{ $t("orderwriteoff") }}</el-button
              >
              <el-upload
                style="display: inline-block"
                class="upload-demo"
                :headers="myHeaders"
                :action="fileUrl"
                :on-success="handleSuccess"
                :show-file-list="false"
              >
                <el-button size="small" type="primary">{{
                  $t("importbatchshipment")
                }}</el-button>
              </el-upload>
              <el-button @click="getDeliveryList">{{
                $t("batchshipmentrecord")
              }}</el-button>
              <el-button @click="downloadLogistics">{{
                $t("downloaontable")
              }}</el-button>
              <el-button size="small" type="primary" @click="batchSend">{{
                $t("batchshipment")
              }}</el-button> -->
            </el-form-item>
          </el-form>
        </div>

        <el-tabs
          v-if="headeNum.length > 0"
          v-model="tableFrom.order_type"
          @tab-click="getList(1), getCardList(), getHeaderList()"
        >
          <el-tab-pane
            v-for="(item, index) in headeNum"
            :key="index"
            :name="item.order_type.toString()"
            :label="item.title + '(' + item.count + ')'"
          />
        </el-tabs>
        <cards-data :card-lists="cardLists" />
      </div>
      <!-- container end  2023-->

      <div class="order_list_mobile" v-if="clientWidth < 1024">
        <div class="item" v-for="(item, index) in tableData.data" :key="index">
          <div class="item_top">
            <div class="orderno">
              {{ $t("orderno") }} :{{ item.order_sn }}
              <span v-show="item.is_del > 0" style="color: #ed4014;">{{
                $t("userdeleted")
              }}</span>
            </div>
            <div class="ordertime">
              {{ $t("ordertime") }} :{{ item.create_time }}
            </div>
          </div>
          <div class="item_middle">
            <div class="info">
              <div v-for="(val, i) in item.orderProduct" :key="i">
                <div class="demo-image__preview">
                  <el-image
                    :src="val.cart_info.product.image"
                    :preview-src-list="[val.cart_info.product.image]"
                  />
                  <span class="tabBox_tit"
                    >{{ val.cart_info.product.store_name + " | "
                    }}{{ val.cart_info.productAttr.sku }}</span
                  >
                  <span class="tabBox_pice">
                    <div class="price">
                      {{ "$" + val.cart_info.productAttr.price }}
                    </div>
                    <div class="num">{{ " x " + val.product_num }}</div>
                  </span>
                </div>
              </div>
            </div>
            <div class="desc">
              <span v-if="item.paid === 0">{{ $t("unpaid") }},</span>
              <span v-else
                >{{ $t("paid") }} <em>${{ item.pay_price }}</em> ,</span
              >
              <span v-if="item.is_del === 0">
                <span v-if="item.paid === 0">{{ $t("unpaid") }}</span>
                <span v-else>
                  <span v-if="item.order_type === 0">{{
                    item.status | orderStatusFilter
                  }}</span>
                  <span v-else>{{ item.status | takeOrderStatusFilter }}</span>
                </span>
              </span>
              <span v-else>{{ $t("deleted") }}</span>
            </div>
          </div>
          <div class="item_bottom">
            <el-button
              v-if="orderFilter(item)"
              type="text"
              size="small"
              @click="onRefundDetail(item.order_sn)"
              >{{ $t("viewrefundform") }}</el-button
            >
            <el-button
              v-if="
                item.paid === 0 && item.is_del === 0 && item.activity_type != 2
              "
              type="text"
              size="small"
              class="mr10"
              @click="edit(item.order_id)"
              >{{ $t("edit") }}</el-button
            >
            <!-- <el-button
              v-if="
                item.order_type == 0 && item.status === 0 && item.paid === 1
              "
              type="text"
              size="small"
              class="mr10"
              @click="send(item.order_id)"
              >{{ $t("shipping") }}</el-button
            > -->
			<el-button
			  v-if="
                item.order_type == 0 && item.status === 0 && item.paid === 1
			  "
			  type="text"
			  size="small"
			  class="mr10"
			  @click="tihuo(item.order_id)"
			  >{{ $t("Go.picked.up") }}</el-button
			>
            <el-button
              v-if="item.status > 0 || item.is_del === 1"
              type="text"
              size="small"
              class="mr10"
              @click="onOrderDetails(item.order_id)"
            ></el-button>
            <el-button
              v-if="item.order_type == 1 && item.paid == 1 && item.status == 0"
              type="text"
              size="small"
              class="mr10"
              @click="handleCancellation(item.verify_code)"
              >{{ $t("towriteoff") }}</el-button
            >
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">
                {{ $t("more") }}
                <i class="el-icon-arrow-down el-icon--right" />
              </span>
              <el-dropdown-menu slot="dropdown">
                <!-- <el-dropdown-item
                  v-if="item.paid === 1 && item.order_type === 0"
                  @click.native="printOrder(item.order_id)"
                  >{{ $t("orderprinting") }}</el-dropdown-item
                > -->
                <el-dropdown-item
                  @click.native="onOrderDetails(item.order_id)"
                  >{{ $t("orderdetails") }}</el-dropdown-item
                >
                <el-dropdown-item @click.native="onOrderLog(item.order_id)">{{
                  $t("orderrecord")
                }}</el-dropdown-item>
                <el-dropdown-item @click.native="onOrderMark(item.order_id)">{{
                  $t("orderremarks")
                }}</el-dropdown-item>
                <el-dropdown-item
                  v-if="item.is_del !== 0"
                  @click.native="handleDelete(item.scope.$index)"
                  >{{ $t("deleteorder") }}</el-dropdown-item
                >

                <el-dropdown-item
                  v-if="
                    item.order_type == 0 && item.status === 1 && item.paid === 1
                  "
                  @click.native="reSend(item.order_id)"
                  >{{ $t("modifyshipmentinfor") }}</el-dropdown-item
                >
                <!--<span v-show="item.is_del > 0" style="color: #ED4014;display: block;">{{ $t('userdeleted') }}</span>-->
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
      </div>

      <div class="order_list_pc" v-if="clientWidth > 1024">
        <el-table
          v-loading="listLoading"
          :data="tableData.data"
          style="width: 100%"
          size="mini"
          class="table"
          highlight-current-row
          :cell-class-name="addTdClass"
        >
          <el-table-column type="expand">
            <template slot-scope="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-form-item :label="$t('totalpriceofgoods')">
                  <span>{{ props.row.total_price | filterEmpty }}</span>
                </el-form-item>
                <el-form-item :label="$t('ordertime')">
                  <span>{{ props.row.create_time }}</span>
                </el-form-item>
                <el-form-item :label="$t('usernotes')">
                  <span style="display: inline-block; width: 200px">{{
                    props.row.mark | filterEmpty
                  }}</span>
                </el-form-item>
                <el-form-item :label="$t('merchantremarks')">
                  <span>{{ props.row.remark | filterEmpty }}</span>
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column width="50">
            <template slot="header" slot-scope="scope">
              <el-popover
                placement="top-start"
                width="100"
                trigger="hover"
                class="tabPop"
              >
                <div>
                  <span
                    class="spBlock onHand"
                    :class="{ check: chkName === 'dan' }"
                    @click="onHandle('dan', scope.$index)"
                    >{{ $t("selectthispage") }}</span
                  >
                  <span
                    class="spBlock onHand"
                    :class="{ check: chkName === 'duo' }"
                    @click="onHandle('duo')"
                    >{{ $t("selectall") }}</span
                  >
                </div>
                <el-checkbox
                  slot="reference"
                  :value="
                    (chkName === 'dan' &&
                      checkedPage.indexOf(tableFrom.page) > -1) ||
                      chkName === 'duo'
                  "
                  @change="changeType"
                />
              </el-popover>
            </template>
            <template slot-scope="scope">
              <el-checkbox
                :value="
                  checkedIds.indexOf(scope.row.order_id) > -1 ||
                    (chkName === 'duo' &&
                      noChecked.indexOf(scope.row.order_id) === -1)
                "
                @change="v => changeOne(v, scope.row)"
              />
            </template>
          </el-table-column>
          <el-table-column :label="$t('orderno')" min-width="170">
            <template slot-scope="scope">
              <span style="display: block" v-text="scope.row.order_sn" />
              <span
                v-show="scope.row.is_del > 0"
                style="color: #ed4014; display: block"
                >{{ $t("userdeleted") }}</span
              >
            </template>
          </el-table-column>
          <el-table-column :label="$t('ordertype')" min-width="100">
            <template slot-scope="scope">
              <span>{{
                scope.row.order_type == 0
                  ? $t("generalorder")
                  : $t("writeofforders")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="$t('activitytype')" min-width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.activity_type != 4">{{
                scope.row.activity_type === 1
                  ? "秒杀"
                  : scope.row.activity_type === 2
                  ? "预售"
                  : scope.row.activity_type === 3
                  ? $t("assist")
                  : "--"
              }}</span>
              <span v-else
                >{{ $t("grouporder") }}
                <span
                  v-if="scope.row.groupUser && scope.row.groupUser.groupBuying"
                  >-{{
                    scope.row.groupUser.groupBuying.status | activityOrderStatus
                  }}</span
                ></span
              >
            </template>
          </el-table-column>
          <el-table-column
            prop="real_name"
            :label="$t('consignee')"
            min-width="130"
          />
          <el-table-column :label="$t('productinformation')" min-width="330">
            <template slot-scope="scope">
              <div
                v-for="(val, i) in scope.row.orderProduct"
                :key="i"
                class="tabBox acea-row row-middle"
              >
                <div class="demo-image__preview">
                  <el-image
                    :src="val.cart_info.product.image"
                    :preview-src-list="[val.cart_info.product.image]"
                  />
                </div>
                <span class="tabBox_tit"
                  >{{ val.cart_info.product.store_name + " | "
                  }}{{ val.cart_info.productAttr.sku }}</span
                >
                <span class="tabBox_pice">
                  <span
                    v-if="
                      scope.row.activity_type === 2 &&
                        val.cart_info.productPresellAttr
                    "
                    >{{
                      "$" +
                        val.cart_info.productPresellAttr.presell_price +
                        " x " +
                        val.product_num
                    }}</span
                  >
                  <span
                    v-else-if="
                      scope.row.activity_type === 3 &&
                        val.cart_info.productAssistAttr
                    "
                    >{{
                      "$" +
                        val.cart_info.productAssistAttr.assist_price +
                        " x " +
                        val.product_num
                    }}</span
                  >
                  <span v-else>{{
                    "$" +
                      val.cart_info.productAttr.price +
                      " x " +
                      val.product_num
                  }}</span>
                  <em
                    v-if="
                      val.refund_num < val.product_num && val.refund_num >= 0
                    "
                    style="color: red; font-style: normal"
                    >(-{{ val.product_num - val.refund_num }})</em
                  >
                </span>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('actualpayment')" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.pay_price }}</span>
              <p v-if="scope.row.finalOrder">
                {{ $t("balancepayment") }}：{{ scope.row.finalOrder.pay_price }}
              </p>
            </template>
          </el-table-column>
          <el-table-column :label="$t('buying.price')" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.real_mer_pay_money }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column :label="$t('ordercommission')" min-width="100">
          <template slot-scope="scope">
            <span>{{
              (
                parseFloat(scope.row.extension_one) +
                parseFloat(scope.row.extension_two) +
                parseFloat(scope.row.refund_extension_one) +
                parseFloat(scope.row.refund_extension_two)
              ).toFixed(2)
            }}</span>
            <em
              v-if="
                scope.row.refund_extension_one > 0 ||
                scope.row.refund_extension_two > 0
              "
              style="color: red; font-style: normal"
              >(-{{
                (
                  parseFloat(scope.row.refund_extension_one) +
                  parseFloat(scope.row.refund_extension_two)
                ).toFixed(2)
              }})</em
            >
          </template>
        </el-table-column> -->
          <el-table-column :label="$t('paymenttype')" min-width="80">
            <template slot-scope="scope">
              <span v-if="scope.row.paid === 1">{{
                scope.row.pay_type | orderPayType
              }}</span>
              <span v-else>--</span>
            </template>
          </el-table-column>
          <el-table-column :label="$t('paymentstatus')" min-width="80">
            <template slot-scope="scope">
              <span>{{
                scope.row.paid === 0 ? $t("unpaid") : $t("paid")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="$t('orderstatus')" min-width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.is_del === 0">
                <span v-if="scope.row.paid === 0">{{ $t("unpaid") }}</span>
                <span v-else>
                  <span v-if="scope.row.order_type === 0">{{
                    scope.row.status | orderStatusFilter
                  }}</span>
                  <span v-else>{{
                    scope.row.status | takeOrderStatusFilter
                  }}</span>
                </span>
              </span>
              <span v-else>{{ $t("deleted") }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="create_time"
            :label="$t('ordertime')"
            min-width="130"
          />
          <el-table-column :label="$t('promoter')" min-width="100">
            <template slot-scope="scope">
              <span>{{
                (scope.row.spread && scope.row.spread.nickname) || $t("nothing")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="$t('superiorpromoter')" min-width="100">
            <template slot-scope="scope">
              <span>{{
                (scope.row.TopSpread && scope.row.TopSpread.nickname) ||
                  $t("nothing")
              }}</span>
            </template>
          </el-table-column>

          <!-- start right 2023 -->
          <el-table-column
            key="8"
            :label="$t('operation')"
            min-width="200"
            fixed="right"
            align="center"
          >
            <template slot-scope="scope">
              <el-button
                v-if="orderFilter(scope.row)"
                type="text"
                size="small"
                @click="onRefundDetail(scope.row.order_sn)"
                >{{ $t("viewrefundform") }}</el-button
              >
              <el-button
                v-if="
                  scope.row.paid === 0 &&
                    scope.row.is_del === 0 &&
                    scope.row.activity_type != 2
                "
                type="text"
                size="small"
                class="mr10"
                @click="edit(scope.row.order_id)"
                >{{ $t("edit") }}</el-button
              >
              <!-- <el-button
                v-if="
                  scope.row.order_type == 0 &&
                    scope.row.status === 0 &&
                    scope.row.paid === 1
                "
                type="text"
                size="small"
                class="mr10"
                @click="send(scope.row.order_id)"
                >{{ $t("shipping") }}</el-button
              > --> 
			<el-button
			  v-if="
				scope.row.order_type == 0 &&
				scope.row.status === 0 &&
				scope.row.paid === 1
			  "
			  type="text"
			  size="small"
			  class="mr10"
			  @click="tihuo(scope.row.order_id)"
			  >{{ $t("Go.picked.up") }}</el-button
			>
              <el-button
                v-if="scope.row.status > 0 || scope.row.is_del === 1"
                type="text"
                size="small"
                class="mr10"
                @click="onOrderDetails(scope.row.order_id)"
              ></el-button>
              <el-button
                v-if="
                  scope.row.order_type == 1 &&
                    scope.row.paid == 1 &&
                    scope.row.status == 0
                "
                type="text"
                size="small"
                class="mr10"
                @click="handleCancellation(scope.row.verify_code)"
                >{{ $t("towriteoff") }}</el-button
              >
              <el-dropdown trigger="click">
                <span class="el-dropdown-link">
                  {{ $t("more") }}
                  <i class="el-icon-arrow-down el-icon--right" />
                </span>
                <el-dropdown-menu slot="dropdown">
                  <!-- <el-dropdown-item
                  v-if="scope.row.paid === 1 && scope.row.order_type === 0"
                  @click.native="printOrder(scope.row.order_id)"
                  >{{ $t("orderprinting") }}</el-dropdown-item
                > -->
                  <el-dropdown-item
                    @click.native="onOrderDetails(scope.row.order_id)"
                    >{{ $t("orderdetails") }}</el-dropdown-item
                  >
                  <el-dropdown-item
                    @click.native="onOrderLog(scope.row.order_id)"
                    >{{ $t("orderrecord") }}</el-dropdown-item
                  >
                  <el-dropdown-item
                    @click.native="onOrderMark(scope.row.order_id)"
                    >{{ $t("orderremarks") }}</el-dropdown-item
                  >
                  <el-dropdown-item
                    v-if="scope.row.is_del !== 0"
                    @click.native="handleDelete(scope.row, scope.$index)"
                    >{{ $t("deleteorder") }}</el-dropdown-item
                  >
                  <!-- <el-dropdown-item
                    v-if="
                      scope.row.order_type == 0 &&
                        scope.row.status === 1 &&
                        scope.row.paid === 1
                    "
                    @click.native="reSend(scope.row.order_id)"
                    >{{ $t("modifyshipmentinfor") }}</el-dropdown-item
                  > -->
                  <!--<span v-show="scope.row.is_del > 0" style="color: #ED4014;display: block;">{{ $t('userdeleted') }}</span>-->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>

    <!--记录-->
    <el-dialog
      :title="$t('operationrecord')"
      :visible.sync="dialogVisible"
      width="700px"
    >
      <el-table
        v-loading="LogLoading"
        border
        :data="tableDataLog.data"
        style="width: 100%"
      >
        <el-table-column
          prop="order_id"
          align="center"
          :label="$t('orderid')"
          min-width="80"
        />
        <el-table-column
          prop="change_message"
          :label="$t('operationrecord')"
          align="center"
          min-width="280"
        />
        <el-table-column
          prop="change_time"
          :label="$t('operationtime')"
          align="center"
          min-width="280"
        />
      </el-table>
      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFromLog.limit"
          :current-page="tableFromLog.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableDataLog.total"
          @size-change="handleSizeChangeLog"
          @current-change="pageChangeLog"
        />
      </div>
    </el-dialog>
    <!--编辑-->
    <el-dialog
      :title="$t('modifyorder')"
      :visible.sync="editVisible"
      width="700px"
    >
      <el-form
        ref="formValidate"
        :model="formValidate"
        label-width="150px"
        @submit.native.prevent
      >
        <el-form-item :label="$t('totalorderprice')">
          <el-input-number
            v-model="formValidate.total_price"
            :min="0"
            :placeholder="$t('please96')"
            @change="changePrice"
          />
        </el-form-item>
        <el-form-item :label="$t('actualpostagepaid')">
          <el-input-number
            v-model="formValidate.pay_postage"
            :min="0"
            :placeholder="$t('please97')"
            @change="changePrice"
          />
        </el-form-item>
        <el-form-item :label="$t('discountamount')">
          <span>{{ formValidate.coupon_price }}</span>
        </el-form-item>
        <el-form-item :label="$t('actualpaymentamount')">
          <span>{{ formValidate.pay_price }}</span>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="editConfirm">{{
          $t("determine")
        }}</el-button>
      </span>
    </el-dialog>
    <!--发送货-->
    <el-dialog
      :title="isBatch ? $t('batchshipment') : $t('orderdelivery')"
      :visible.sync="sendVisible"
      width="700px"
      :before-close="handleClose"
    >
      <el-form
        ref="shipment"
        :model="shipment"
        :rules="rules"
        label-width="120px"
        @submit.native.prevent
      >
        <el-form-item
          v-if="isResend && noLogistics != 3"
          :label="
            shipment.delivery_type == 1 || shipment.delivery_type == 4
              ? $t('Former.express.company')
              : $t('shippersname')
          "
        >
          <span>{{ original.delivery_name }}</span>
        </el-form-item>
        <el-form-item
          v-if="isResend && noLogistics != 3"
          :label="
            shipment.delivery_type == 1 || shipment.delivery_type == 4
              ? $t('Original.express.bill.No')
              : $t('Shippers.mobile.number')
          "
        >
          <span>{{ original.delivery_id }}</span>
        </el-form-item>
        <el-form-item :label="$t('selecttype')" prop="delivery_type">
          <el-radio-group v-model="shipment.delivery_type" @change="changeSend">
            <el-radio :label="1">{{ $t("manualshipment") }}</el-radio>
            <el-radio :label="2">{{ $t("delivery") }}</el-radio>
            <el-radio :label="3" class="radio">{{
              $t("nodeliveryrequired")
            }}</el-radio>
            <el-radio v-if="isDump" :label="4" class="radio">{{
              $t("electronicfacesheetprinting")
            }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 1 || shipment.delivery_type == 4"
          :label="$t('courierservices')"
          prop="delivery_name"
        >
          <el-select
            v-model="shipment.delivery_name"
            :placeholder="$t('please100')"
            class="filter-item selWidth mr20"
            @change="getTempsLst(shipment.delivery_name)"
          >
            <el-option
              v-for="item in deliveryList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 1 && !isBatch"
          :label="$t('couriernumber')"
          prop="delivery_id"
        >
          <el-input
            v-model="shipment.delivery_id"
            :placeholder="$t('please98')"
          />
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 4"
          :label="$t('electronicsheet')"
          prop="temp_id"
        >
          <el-select
            v-model="shipment.temp_id"
            :placeholder="$t('please106')"
            class="filter-item selWidth mr20"
          >
            <el-option
              v-for="(item, index) in eleTempsLst"
              :key="item.temp_id + index"
              :label="item.title"
              :value="item.temp_id"
            />
          </el-select>
          <el-button type="text" @click="getPicture()">{{
            $t("preview")
          }}</el-button>
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 4"
          :label="$t('nameofsender')"
          prop="from_name"
        >
          <el-input
            v-model="shipment.from_name"
            :placeholder="$t('please101')"
          />
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 4"
          :label="$t('senderstelephone')"
          prop="from_tel"
        >
          <el-input
            v-model="shipment.from_tel"
            :placeholder="$t('please102')"
          />
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 2"
          :label="$t('shippersname')"
          prop="to_name"
        >
          <el-input v-model="shipment.to_name" :placeholder="$t('please107')" />
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 2"
          :label="$t('shipperstelephone')"
          prop="to_phone"
        >
          <el-input
            v-model="shipment.to_phone"
            :placeholder="$t('please108')"
          />
        </el-form-item>
        <el-form-item
          v-if="shipment.delivery_type == 4"
          :label="$t('returnaddress')"
          prop="from_addr"
        >
          <el-input
            v-model="shipment.from_addr"
            type="textarea"
            :placeholder="$t('please103')"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="sendVisible = false">{{ $t("cancel") }}</el-button>
        <el-button type="primary" @click="submitForm('shipment')">{{
          $t("submit")
        }}</el-button>
      </span>
    </el-dialog>
    <!--电子面单预览-->
    <el-dialog
      v-if="pictureVisible"
      :visible.sync="pictureVisible"
      width="500px"
    >
      <img :src="pictureUrl" class="pictures" />
    </el-dialog>
    <!--详情-->
    <details-from ref="orderDetail" />
    <!--导出订单列表-->
    <file-list ref="exportList" />
    <!--导出订单列表-->
    <delivery-record ref="deliveryList" />
  </div>
</template>

<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
  orderListApi,
  chartApi,
  orderUpdateApi,
  orderDetailApi,
  orderDeliveryApi,
  batchDeliveryApi,
  orderLogApi,
  orderDeleteApi,
  orderRemarkApi,
  orderPrintApi,
  exportOrderApi,
  orderCancellationApi,
  orderHeadListApi,
  exportInvoiceApi,
  cardListApi,
  expressLst,
  exprTempsLst,
  getEleTempData,
  orderPickUpApi
} from "@/api/order";
import { serveInfoApi } from "@/api/setting";
import detailsFrom from "./orderDetail";
import fileList from "@/components/exportFile/fileList";
import deliveryRecord from "@/components/deliveryRecord/index";
import cardsData from "@/components/cards/index";
import { getToken } from "@/utils/auth";
import SettingMer from "@/libs/settingMer";
import { roterPre } from "@/settings";
export default {
  components: {
    detailsFrom,
    cardsData,
    fileList,
    deliveryRecord
  },
  data() {
    return {
      fileUrl: SettingMer.https + "/store/import/delivery",
      myHeaders: { "X-Token": getToken() },
      orderId: 0,
      tableData: {
        data: [],
        total: 0
      },
      clientWidth:'',
      listLoading: true,
      roterPre: roterPre,
      tableFrom: {
        order_sn: this.$route.query.order_sn ? this.$route.query.order_sn : "",
        group_order_sn: "",
        order_type: "-1",
        keywords: "",
        store_name: "",
        status: "",
        date: "",
        page: 1,
        limit: 20,
        type: "1",
        username: "",
        order_id: this.$route.query.id ? this.$route.query.id : "",
        activity_type: ""
      },
      activityList: [
        { value: 0, label: this.$t("generalorder") },
        { value: 1, label: this.$t("secondkillorder") },
        { value: 2, label: this.$t("presaleorder") },
        { value: 3, label: this.$t("helporder") },
        { value: 4, label: this.$t("grouporder") }
      ],
      orderChartType: {},
      timeVal: [],
      fromList: {
        title: this.$t("selectionperiod"),
        custom: true,
        fromTxt: [
          {
            text: this.$t("all"),
            val: ""
          },
          {
            text: this.$t("today"),
            val: "today"
          },
          {
            text: this.$t("yesterday"),
            val: "yesterday"
          },
          {
            text: this.$t("last7days"),
            val: "lately7"
          },
          {
            text: this.$t("last30days"),
            val: "lately30"
          },
          {
            text: this.$t("thismonth"),
            val: "month"
          },
          {
            text: this.$t("thisyear"),
            val: "year"
          }
        ]
      },
      selectionList: [],
      ids: "",
      tableFromLog: {
        page: 1,
        limit: 10
      },
      tableDataLog: {
        data: [],
        total: 0
      },
      LogLoading: false,
      dialogVisible: false,
      fileVisible: false,
      editVisible: false,
      sendVisible: false,
      pictureVisible: false,
      cardLists: [],
      orderDatalist: null,
      headeNum: [],
      editId: "",
      formValidate: {
        total_price: "",
        pay_postage: "",
        pay_price: "",
        coupon_price: ""
      },
      deliveryList: [],
      eleTempsLst: [],
      shipment: {
        delivery_type: 1
      },
      original: {
        delivery_name: "",
        delivery_id: ""
      },
      isResend: false,
      chkName: "",
      checkedPage: [],
      checkedIds: [], // 订单当前页选中的数据
      noChecked: [], // 订单全选状态下当前页不选中的数据
      allCheck: false,
      isBatch: false,
      delivery_name: "",
      isDump: false,
      noLogistics: false,
      rules: {
        delivery_type: [
          { required: true, message: this.$t("please99"), trigger: "change" }
        ],
        delivery_name: [
          { required: true, message: this.$t("please100"), trigger: "change" }
        ],
        to_name: [
          { required: true, message: this.$t("please107"), trigger: "blur" }
        ],
        delivery_id: [
          { required: true, message: this.$t("please98"), trigger: "blur" }
        ],
        to_phone: [
          { required: true, message: this.$t("please108"), trigger: "blur" },
          {
            pattern: /^1[3456789]\d{9}$/,
            message: this.$t("please105"),
            trigger: "blur"
          }
        ],
        temp_id: [
          { required: true, message: this.$t("please106"), trigger: "change" }
        ],
        from_name: [
          { required: true, message: this.$t("please101"), trigger: "blur" }
        ],
        from_tel: [
          { required: true, message: this.$t("please102"), trigger: "blur" },
          {
            pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
            message: this.$t("please104"),
            trigger: "blur"
          }
        ],
        from_addr: [
          { required: true, message: this.$t("please103"), trigger: "blur" }
        ]
      }
    };
  },
  mounted() {
    if (this.$route.query.hasOwnProperty("order_sn")) {
      this.tableFrom.order_sn = this.$route.query.order_sn;
    } else {
      this.tableFrom.order_sn = "";
    }
    this.clientWidth = document.body.clientWidth;
    this.isOpenDump();
    this.headerList();
    this.getCardList();
    this.getExpressLst();
    this.getList(1);
    this.getHeaderList();
    // this.randdanhao();
  },
  methods: {
    // 是否开启分单发货
    // onchangeIsSeperate() {

    // },
    // 是否开启电子面单
    isOpenDump() {
      serveInfoApi()
        .then(res => {
          this.isDump = res.data.crmeb_serve_dump;
          if (res.data.crmeb_serve_dump) this.getEleTempData();
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    // 获取快递公司列表
    getExpressLst() {
      expressLst()
        .then(res => {
          this.deliveryList = res.data;
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    // 获取电子面单列表
    getTempsLst(name) {
      exprTempsLst({ com: name }).then(res => {
        this.eleTempsLst = res.data.data;
      });
    },
    // 获取电子面单默认数据
    getEleTempData() {
      getEleTempData()
        .then(res => {
          const data = res.data;
          const delivery_type = this.shipment.delivery_type;
          this.shipment = {
            from_name: data.mer_from_name,
            from_addr: data.mer_from_addr,
            from_tel: data.mer_from_tel,
            delivery_type: delivery_type,
            delivery_name: data.mer_from_com,
            temp_id: data.mer_config_temp_id
          };

          this.getTempsLst(data.mer_from_com);
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    changeSend() {},
    getPicture(name) {
      if (this.shipment.temp_id) {
        this.eleTempsLst.forEach((o, i) => {
          if (o["temp_id"] == this.shipment.temp_id) {
            this.pictureVisible = true;
            this.pictureUrl = o["pic"];
          }
        });
      } else {
        this.$message.error(this.$t("please174"));
      }
    },
    // 批量发送货
    batchSend() {
      if (this.checkedIds.length == 0) {
        return this.$message.warning(this.$t("please173"));
      } else {
        this.isBatch = true;
        this.sendVisible = true;
        this.shipment.delivery_type = 2;
        this.shipment.order_id = this.checkedIds;
      }
    },
    handleClose() {
      this.sendVisible = false;
      //   this.sendReset()
    },
    onHandle(name) {
      this.chkName = this.chkName === name ? "" : name;
      this.changeType(!(this.chkName === ""));
    },
    changeType(v) {
      if (v) {
        if (!this.chkName) {
          this.chkName = "dan";
        }
      } else {
        this.chkName = "";
        this.allCheck = false;
      }
      const index = this.checkedPage.indexOf(this.tableFrom.page);
      if (this.chkName === "dan") {
        this.checkedPage.push(this.tableFrom.page);
      } else if (index > -1) {
        this.checkedPage.splice(index, 1);
      }
      this.syncCheckedId();
    },
    syncCheckedId() {
      const ids = this.tableData.data.map(v => v.order_id);
      if (this.chkName === "duo") {
        this.checkedIds = [];
        this.allCheck = true;
      } else if (this.chkName === "dan") {
        this.allCheck = false;
        ids.forEach(id => {
          const index = this.checkedIds.indexOf(id);
          if (index === -1) {
            this.checkedIds.push(id);
          }
        });
      } else {
        ids.forEach(id => {
          const index = this.checkedIds.indexOf(id);
          if (index > -1) {
            this.checkedIds.splice(index, 1);
          }
        });
      }
    },
    // 分开选择
    changeOne(v, row) {
      if (v) {
        if (this.chkName === "duo") {
          const index = this.noChecked.indexOf(row.order_id);
          if (index > -1) this.noChecked.splice(index, 1);
        } else {
          const index = this.checkedIds.indexOf(row.order_id);
          if (index === -1) this.checkedIds.push(row.order_id);
        }
      } else {
        if (this.chkName === "duo") {
          const index = this.noChecked.indexOf(row.order_id);
          if (index === -1) this.noChecked.push(row.order_id);
        } else {
          const index = this.checkedIds.indexOf(row.order_id);
          if (index > -1) this.checkedIds.splice(index, 1);
        }
      }
    },
    // 头部
    getHeaderList() {
      orderHeadListApi()
        .then(res => {
          this.headeNum = res.data;
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    // 订单筛选
    orderFilter(item) {
      let status = false;
      item.orderProduct.forEach(el => {
        if (el.refund_num < el.product_num) {
          status = true;
        }
      });
      return status;
    },
    // 退款详情页
    onRefundDetail(sn) {
      this.$router.push({
        path: "refund",
        query: {
          sn: sn
        }
      });
    },
    // 表格某一行添加特定的样式
    addTdClass(val) {
      if (val.row.status > 0 && val.row.paid == 1) {
        for (let i = 0; i < val.row.orderProduct.length; i++) {
          if (
            val.row.orderProduct[i].refund_num >= 0 &&
            val.row.orderProduct[i].refund_num <
              val.row.orderProduct[i].product_num
          ) {
            return "row-bg";
          }
        }
      } else {
        return " ";
      }
    },
    // 详情
    onOrderDetails(id) {
      this.orderId = id;
      this.$refs.orderDetail.dialogVisible = true;
      this.$refs.orderDetail.onOrderDetails(id);
    },
    // 生成订单
    exportOrder() {
      exportOrderApi(this.tableFrom)
        .then(res => {
          const h = this.$createElement;
          this.$msgbox({
            title: this.$t("tips"),
            message: h("p", null, [
              h("span", null, this.$t("please71")),
              h("span", { style: "color: teal" }, this.$t("exportrecords")),
              h("span", null, this.$t("see"))
            ]),
            confirmButtonText: this.$t("igotit")
          }).then(action => {
            this.$router.push({ path: this.roterPre + "/export/list" });
          });
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    // 生成发货单
    exportInvoice() {
      exportInvoiceApi(this.tableFrom)
        .then(res => {
          const h = this.$createElement;
          this.$msgbox({
            title: this.$t("tips"),
            message: h("p", null, [
              h("span", null, this.$t("please71")),
              h("span", { style: "color: teal" }, this.$t("exportrecords")),
              h("span", null, this.$t("see"))
            ]),
            confirmButtonText: this.$t("igotit")
          }).then(action => {
            this.$router.push({ path: this.roterPre + "/export/list" });
          });
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    getExportFileList() {
      this.fileVisible = true;
      this.$refs.exportList.exportFileList();
    },
    // 批量发货记录
    getDeliveryList() {
      this.$refs.deliveryList.getList();
    },
    // 上传成功
    handleSuccess(response) {
      if (response.status === 200) {
        this.$message.success(response.message);
        // this.getFileList("");
      } else {
        this.$message.error(response.message);
      }
    },
    // 下载物流公司对照表
    downloadLogistics() {
      window.open(
        SettingMer.https + `/excel/download/express?token=` + getToken()
      );
    },
    // 订单核销
    orderCancellation() {
      const that = this;
      this.$prompt("", this.$t("tips"), {
        confirmButtonText: this.$t("writeoffimmediately"),
        cancelButtonText: this.$t("cancel"),
        inputPattern: /\S/,
        inputPlaceholder: this.$t("please109"),
        inputErrorMessage: this.$t("please109")
      })
        .then(({ value }) => {
          that.handleCancellation(value);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: this.$t("cancelinput")
          });
        });
    },
    // 去核销
    handleCancellation(code) {
      this.$confirm(this.$t("areyousuretowriteoffthisorder"), this.$t("tips"), {
        confirmButtonText: this.$t("determine"),
        cancelButtonText: this.$t("cancel"),
        type: "warning"
      })
        .then(() => {
          orderCancellationApi(code)
            .then(res => {
              this.$message.success(res.message);
              this.getList("");
            })
            .catch(res => {
              this.$message.error(res.message);
              this.LogLoading = false;
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: this.$t("cancelledwriteoff")
          });
        });
    },
    // 订单记录
    onOrderLog(id) {
      this.dialogVisible = true;
      this.LogLoading = true;
      orderLogApi(id, this.tableFromLog)
        .then(res => {
          this.tableDataLog.data = res.data.list;
          this.tableDataLog.total = res.data.count;
          this.LogLoading = false;
        })
        .catch(res => {
          this.$message.error(res.message);
          this.LogLoading = false;
        });
    },
    pageChangeLog(page) {
      this.tableFromLog.page = page;
      this.getList("");
    },
    handleSizeChangeLog(val) {
      this.tableFromLog.limit = val;
      this.getList("");
    },
    // 打印订单
    printOrder(id) {
      orderPrintApi(id)
        .then(res => {
          this.$message.success(res.message);
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    // 订单删除
    handleDelete(row, idx) {
      if (row.is_del === 1) {
        this.$modalSure().then(() => {
          orderDeleteApi(row.order_id)
            .then(({ message }) => {
              this.$message.success(message);
              this.tableData.data.splice(idx, 1);
            })
            .catch(({ message }) => {
              this.$message.error(message);
            });
        });
      } else {
        this.$confirm(
          "您选择的的订单存在用户未删除的订单，无法删除用户未删除的订单！",
          this.$t("tips"),
          {
            confirmButtonText: this.$t("determine"),
            type: "error"
          }
        );
      }
    },
    // 备注
    onOrderMark(id) {
      this.$modalForm(orderRemarkApi(id)).then(() => this.getList(""));
    },
    handleSelectionChange(val) {
      this.selectionList = val;
      const data = [];
      this.selectionList.map(item => {
        data.push(item.id);
      });
      this.ids = data.join(",");
    },
    // 选择时间
    selectChange(tab) {
      this.timeVal = [];
      this.tableFrom.date = tab;
      this.getCardList();
      this.getList(1);
    },
    // 具体日期
    onchangeTime(e) {
      this.timeVal = e;
      this.tableFrom.date = e ? this.timeVal.join("-") : "";
      this.getCardList();
      this.getList(1);
    },
    // 编辑
    edit(id) {
      // this.$modalForm(orderUpdateApi(id)).then(() => this.getList(''));
      this.editId = id;
      this.editVisible = true;
      orderDetailApi(id)
        .then(res => {
          this.formValidate = {
            pay_postage: res.data.pay_postage,
            total_price: res.data.total_price,
            coupon_price: res.data.coupon_price,
            pay_price: (
              Number(res.data.total_price) +
              Number(res.data.pay_postage) -
              Number(res.data.coupon_price)
            ).toFixed(2)
          };
          this.loading = false;
        })
        .catch(({ message }) => {
          this.loading = false;
          this.$message.error(message);
        });
    },
    editConfirm() {
      orderUpdateApi(this.editId, this.formValidate)
        .then(res => {
          this.editVisible = false;
          this.$message.success(res.message);
          this.getList("");
        })
        .catch(({ message }) => {
          this.$message.error(message);
        });
    },
    changePrice() {
      this.formValidate.pay_price = (
        this.formValidate.total_price +
        this.formValidate.pay_postage -
        this.formValidate.coupon_price
      ).toFixed(2);
    },
    // 发货
    send(id) {
      //   this.$modalForm(orderDeliveryApi(id)).then(() => this.getList(''))
      this.isBatch = false;
      this.sendVisible = true;
      this.isResend = false;
      this.orderId = id;
      this.$set(this.shipment, "delivery_id", this.randnum());
      delete this.shipment.order_id;
    },
	tihuo(id){
		this.$confirm(this.$t("picked.up.yn"), this.$t("tips"), {
			confirmButtonText: this.$t("determine"),
			cancelButtonText: this.$t("cancel"),
			type: "warning",
		})
		.then(() => {
			orderPickUpApi(id)
			.then((res) => {
				this.$message.success(res.message);
				this.getList("");
			})
			.catch((res) => {
				this.$message.error(res.message);
				if(res.data.message=='Sorry, your balance is insufficient, please contact customer service'){
					this.$router.push({ path: this.roterPre + "/accounts/recharge" });
				}
			});
		})
		.catch(() => {
			this.$message({
			type: "info",
			message: this.$t("canceled"),
			});
		});
	},
    randnum() {
      var Randnum = "";
      for (var i = 0; i < 12; i++) {
        Randnum += Math.floor(Math.random() * 10);
      }
      return Randnum;
    },
    sendReset() {
      this.shipment = {
        delivery_type: 1,
        delivery_name: "",
        delivery_id: "",
        from_name: "",
        from_addr: "",
        from_tel: "",
        temp_id: ""
      };
    },
    // 修改发货信息
    reSend(id) {
      this.isBatch = false;
      this.sendVisible = true;
      this.orderId = id;
      this.isResend = true;
      delete this.shipment.order_id;
      orderDetailApi(id)
        .then(res => {
          const data = res.data;
          this.shipment.delivery_type =
            !this.isDump && data.delivery_type == 4
              ? 1
              : Number(data.delivery_type);
          this.noLogistics = data.delivery_type;
          this.loading = false;
          this.original = {
            delivery_name: data.delivery_name,
            delivery_id: data.delivery_id
          };
          this.loading = false;
        })
        .catch(({ message }) => {
          this.loading = false;
          this.$message.error(message);
        });
    },
    submitForm(name) {
      if (this.shipment.delivery_type == 2) {
        this.shipment.delivery_name = this.shipment.to_name;
        this.shipment.delivery_id = this.shipment.to_phone;
      }
      this.$refs[name].validate(valid => {
        if (valid) {
          delete this.shipment.to_name;
          delete this.shipment.to_phone;
          this.isBatch
            ? batchDeliveryApi(this.shipment, this.shipment)
                .then(res => {
                  this.sendVisible = false;
                  this.$message.success(res.message);
                  this.getList("");
                  // this.$refs[name].resetFields()
                  this.sendReset();
                })
                .catch(({ message }) => {
                  this.$message.error(message);
                  if (
                    message ==
                    "Sorry, your balance is insufficient, please contact customer service"
                  ) {
                    this.$router.push({
                      path: this.roterPre + "/accounts/recharge"
                    });
                  }
                })
            : orderDeliveryApi(this.orderId, this.shipment)
                .then(res => {
                  this.sendVisible = false;
                  this.$message.success(res.message);
                  this.getList("");
                  //   this.$refs[name].resetFields()
                  this.sendReset();
                })
                .catch(({ message }) => {
                  this.$message.error(message);
                  if (
                    message ==
                    "Sorry, your balance is insufficient, please contact customer service"
                  ) {
                    this.$router.push({
                      path: this.roterPre + "/accounts/recharge"
                    });
                  }
                });
        } else {
          return;
        }
      });
    },
    // 列表
    getList(num) {
      this.listLoading = true;
      this.tableFrom.page = num || this.tableFrom.page;
      orderListApi(this.tableFrom)
        .then(res => {
          this.tableData.data = res.data.list;
          this.tableData.total = res.data.count;
          //   this.cardLists = res.data.stat
          this.listLoading = false;
        })
        .catch(res => {
          this.$message.error(res.message);
          this.listLoading = false;
        });
    },
    getCardList() {
      cardListApi(this.tableFrom)
        .then(res => {
          this.cardLists = res.data;
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    },
    pageChange(page) {
      this.tableFrom.page = page;
      this.getList("");
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val;
      this.getList("");
    },
    headerList() {
      chartApi()
        .then(res => {
          this.orderChartType = res.data;
        })
        .catch(res => {
          this.$message.error(res.message);
        });
    }
  }
};
</script>

<style lang="scss" scoped>
.pictures {
  max-width: 100%;
}

.area-desc {
  margin: 0;
  color: #999;
  font-size: 12px;
}

.selWidth {
  width: 300px;
}

.spBlock {
  cursor: pointer;
  display: block;
  padding: 5px 0;
}

.check {
  color: #00a2d4;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
  font-size: 12px;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.tabBox_tit {
  width: 53%;
  font-size: 12px !important;
  margin: 0 2px 0 10px;
  letter-spacing: 1px;
  padding: 5px 0;
  box-sizing: border-box;
}

::v-deep.row-bg {
  .cell {
    color: red !important;
  }
}

.headTab {
  position: relative;

  .headBtn {
    position: absolute;
    right: 0;
    top: -6px;
  }
}

.dropdown {
  padding: 0 10px;
  border: 1px solid #409eff;
  margin-right: 10px;
  line-height: 28px;
  border-radius: 4px;
}
</style>
